package com.yeswater.multithread.chapter1.test1_13;

import org.junit.Test;

/**
 * author : yeswater
 * date : 2023/10/19
 */

public class RunTest {

    /**
     * yield() 放弃当前的 CPU 资源,让其他任务去占用 CPU
     */
    @Test
    public void test1() {
        Thread t = new Thread(() -> {
            // Thread.yield();
            long begin = System.currentTimeMillis();
            int count = 0;
            for (int i = 0; i < 500000; i++) {
                count = count + (i + 1);
            }
            long end = System.currentTimeMillis();
            System.out.println(" 用时: " + (end - begin) + " 毫秒");
        });
        t.start();
    }

}
